using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using DataAccessLayer;

public partial class DoctorRegistration : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Common c = new Common();
        string conn = c.fetchConnString();
        Doctor docReg = new Doctor(conn);
        List<string> lstSpecialization = new List<string>();
        DataTable dtSpecialization = docReg.LoadSpecialization();

        foreach (DataRow drRow in dtSpecialization.Rows)
            lstSpecialization.Add(drRow[0].ToString());

        ddlSpecialization.DataSource = lstSpecialization;
        ddlSpecialization.DataBind();
    }
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        Common c = new Common();
        string conn = c.fetchConnString();
        Doctor drg = new Doctor(conn);
        int reg = Convert.ToInt32(txtRegNo.Text);
        drg.REGNO = Convert.ToInt32(txtRegNo.Text.Trim(' ', ',', '.'));
        drg.NAME = txtName.Text.Trim(' ');
        drg.EMAIL = txtEmail.Text.Trim(' ');
        drg.PASSWORD = txtPassword.Text;
        drg.DOB = txtDob.Text;
        drg.GENDER = ddlGender.SelectedItem.Text;
        drg.SPECIAL = ddlSpecialization.SelectedItem.Text;
        drg.DEGREE = txtDegree.Text.Trim(' ');
        int temp = drg.funcVerification(reg);
        if (temp == 1)
        {
            lblError.Visible = true;
        }
        else
        {
            drg.funcRegistration();
            Response.Redirect("Home.aspx");
        }
    }
    protected void calDob_SelectionChanged(object sender, EventArgs e)
    {
        txtDob.Text = calDob.SelectedDate.ToShortDateString();
    }
    protected void lnkAboutUs_Click(object sender, EventArgs e)
    {
        Response.Redirect("About Us.aspx");
    }
    protected void lnkContactUs_Click(object sender, EventArgs e)
    {
        Response.Redirect("Contact Us.aspx");
    }
    protected void lnkFeedback_Click(object sender, EventArgs e)
    {
        Response.Redirect("Feedback.aspx");
    }
    protected void imgbtnHome_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("Home.aspx");
    }
}
